const fs = require("fs");
const path = require("path");

const srcDir = process.argv[2];
const destDir = process.argv[3];

// const num = "fileCopy";
const srcPath = path.resolve(__dirname, srcDir);
const destPath = path.resolve(__dirname, destDir);
// if (fs.existsSync(destPath))
fs.mkdir(destPath, (err) => {
  if (!err) console.log("文件创建成功开始拷贝....");
  const srcFiles = fs.readdirSync(srcPath);
  for (const file of srcFiles) {
    if (file.endsWith(".html")) {
      const srcFile = path.resolve(srcPath, file);
      const destFile = path.resolve(destPath, file);
      fs.copyFileSync(srcFile, destFile);
      console.log("拷贝成功");
    }
  }
});
